package com.SunSoft.PhoneRemoteControl;

import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Handler;
import android.os.Message;

final class ff
  implements Runnable
{
  public final void run()
  {
    while (true)
    {
      int i;
      Object localObject1;
      String str;
      if (this.a.G)
        return;
      if ((((this.a.k > Show_Search.c(this.a) + 1) || (this.a.S != 1))) && (!(this.a.R)))
        continue;
      if (((!(this.a.Q)) && (!(this.a.R))) || (this.a.k > Show_Search.c(this.a)))
      {
        if ((this.a.k < Show_Search.c(this.a)) || (!(this.a.Q)))
          continue;
        this.a.Q = false;
        localObject1 = new Message();
        ((Message)localObject1).what = 4;
        this.a.aC.sendMessage((Message)localObject1);
      }
      if (this.a.U)
        if (Show_Search.b(this.a) == 0)
          Show_Search.a(this.a, "");
      try
      {
        Thread.sleep(500L);
        this.a.U = false;
        localObject1 = this.a;
        ((Show_Search)localObject1).k += this.a.aj;
        str = Show_Search.d(this.a)[(this.a.k - 1)].c;
        this.a.al = "\n" + Show_Search.d(this.a)[(this.a.k - 1)].a;
        Object localObject3 = Show_Search.d(this.a)[(this.a.k - 1)].f;
        if (localObject3 != null)
        {
          localObject1 = localObject3;
          if (((String)localObject3).length() > 8)
            localObject1 = ((String)localObject3).substring(0, 8);
          localObject1 = ((String)localObject1).replace("|", ",");
          this.a.al = this.a.al + "," + ((String)localObject1);
        }
        Show_Search.a("Test", "test_but_id:" + String.valueOf(this.a.ai));
        if (this.a.af != 5)
          break label703;
        i = Integer.valueOf(Show_Search.d(this.a)[(this.a.k - 1)].e).intValue();
        Show_Search.a("Test", "temp_model_id:" + String.valueOf(i));
        localObject1 = this.a;
        localObject3 = this.a.ac;
        ((Show_Search)localObject1).av = di.a(i, this.a.ai, this.a.au);
        if ((this.a.av != null) && (this.a.av.length == 7))
          this.a.ak = this.a.av[0];
        Show_Search.a("Test", "cur_test_count:" + String.valueOf(this.a.k));
        localObject1 = new Message();
        ((Message)localObject1).what = 2;
        this.a.aC.sendMessage((Message)localObject1);
        if (!(this.a.R))
        {
          i = 0;
          if (i < 120)
            break label826;
          this.a.M = false;
        }
        localObject1 = new Message();
        ((Message)localObject1).what = 6;
        this.a.aC.sendMessage((Message)localObject1);
        if ((this.a.Q) && (!(this.a.R)))
        {
          localObject1 = this.a;
          ((Show_Search)localObject1).k += 1;
        }
        this.a.aj = 0;
        label814: label826: label703: this.a.R = false;
      }
      catch (InterruptedException localInterruptedException2)
      {
        while (true)
        {
          Object localObject2;
          do
            while (true)
            {
              while (true)
              {
                do
                {
                  while (true)
                    localInterruptedException1.printStackTrace();
                  i = this.a.ai;
                  localObject2 = Show_Search.f(this.a).rawQuery("select ID,control_ID,code_str,dis_ch,dis_en,note,order_ID,define_ID  from button_data where define_ID = ? and order_ID=?", new String[] { str, String.valueOf(i) });
                  if (!(((Cursor)localObject2).moveToNext()))
                    break label814;
                  this.a.ak = ((Cursor)localObject2).getString(((Cursor)localObject2).getColumnIndex("code_str"));
                }
                while ((this.a.ak == null) || (this.a.ak.length() <= 5));
                this.a.ak = Show_Search.a(this.a.ak);
              }
              this.a.ak = "";
            }
          while (!(this.a.Q));
          try
          {
            do
            {
              Thread.sleep(this.a.ae);
              if (i != 50)
                continue;
              localObject2 = new Message();
              ((Message)localObject2).what = 7;
              this.a.aC.sendMessage((Message)localObject2);
            }
            while (!(this.a.Q));
            i += 1;
          }
          catch (InterruptedException localInterruptedException2)
          {
            while (true)
              localInterruptedException2.printStackTrace();
          }
        }
      }
    }
  }
}